/* 
*@module: 
*@module: provide echarts data(ground) for src/views/echart/index.vue
*@author:刘千红
*/
const theDatabase = require('../../config/db.js').theDb; //引入数据库
const echartSchema = theDatabase.import('../../schema/sample_lab_ground_info.js');
const radarSchema = theDatabase.import('../../schema/reference_info.js');
const sample_histogram_statistic_value_Schema = theDatabase.import('../../schema/sample_ground_histogram_statistic_value.js');
const sample_type2_statistic_value_Schema = theDatabase.import('../../schema/sample_type2_ground_statistic_value.js');
class echart_Model{
   
    /**
     *获取柱状图传入元素的数据
     *
     * @static
     * @param {*} point_num
     * @param {*} element
     * @returns
     * @memberof echart_Model
     */
    static async getHistogramElement(point_num, element) {
        let AllElementData
        if (element) {
    
            AllElementData = await sample_histogram_statistic_value_Schema.findAll({
                attributes: [element, 'assess_type', 'statistic_value'],
                where: {
                    point_num,
                  
    
                }
            })
    
        }
        return AllElementData
    }
    
    /**
     *获取雷达图数据各深度元素值
     *
     * @static
     * @param {*} point_num
     * @param {*} assess_type
     * @returns
     * @memberof echart_Model
     */
    static async getData(point_num, assess_type) {
        const FoldData = await echartSchema.findAll({
            attributes: { exclude: ['id', 'project_num', 'sample_num', 'assess_type', 'count', 'remarks', 'date', 'attention', 'point_num', 'lat', 'lng'] },
            where: {
                point_num,
                assess_type,
            }
        })
        return FoldData
    }
    
    /**
     *获取元素国标值
     *
     * @static
     * @param {*} type
     * @returns
     * @memberof echart_Model
     */
    static async getAllRadarData (type) {
        const AllDatarData = await radarSchema.findAll(
            {
                attributes: { exclude: ['id', 'type', 'point_num'] },
                where: {
                    type,
                }
            }
        )
        return AllDatarData
    }
    
    /**
     *获取在详细调查阶段，雷达图各深度的值
     *
     * @static
     * @param {*} assess_type
     * @param {*} point_num
     * @returns
     * @memberof echart_Model
     */
    static async RadarEachDepthValue (assess_type, point_num) {
        const SelectOptions = await sample_type2_statistic_value_Schema.findAll({
            attributes: { exclude: ['assess_type', 'id', 'point_num', 'remarks'] },
            where: {
                assess_type,
                point_num,
    
            }
        })
        return SelectOptions
    }
    
    /**
     *获取ground 3D柱状图的数据
     *
     * @static
     * @param {*} point_num
     * @param {*} assess_type
     * @param {*} element
     * @returns
     * @memberof echart_Model
     */
    static async echartBar3DValue(point_num, assess_type, element) {
        let AllElementData
        if (element) {
    
            AllElementData = await echartSchema.findAll({
                attributes: ['sample_depth', 'lng', 'lat', element],
                where: {
                    point_num,
                    assess_type,
    
    
                }
            })
    
        }
        return AllElementData
    }

    /**
     *取出基本表中的数据计算平均值
     *
     * @static
     * @param {*} sample_depth
     * @param {*} assess_type
     * @returns
     * @memberof echart_Model
     */
    static async getFoldData (sample_depth,assess_type) {
        const FoldData = await echartSchema.findAll({
            attributes: {exclude: ['id','project_num','sample_num','assess_type','count','remarks','date','attention','lat','lng']},
            where: {
                sample_depth,
                assess_type,
            }
        })
        return FoldData
    }

    /**
     *通过类型查找数据库数据
     *
     * @static
     * @param {*} assess_type
     * @returns
     * @memberof echart_Model
     */
    static async getType3ElementData (assess_type){
        const AllElementData = await echartSchema.findAll(
            {
                attributes: {exclude: ['id','sample_num','project_num','date','sample_depth','count','lat','lng']},
                where: {
                    assess_type
                }
            }
        )
        return AllElementData
    }
    
    /**
     *通过调查类型取出各元素的数值
     *
     * @static
     * @param {*} assess_type
     * @returns
     * @memberof echart_Model
     */
    static async getElementData (assess_type){
        const AllElementData = await echartSchema.findAll(
            {
                attributes: {exclude: ['id','sample_num','project_num','date','sample_depth','count','lat','lng']},
                where: {
                    assess_type
                }
            }
        )
        return AllElementData
    }



}

module.exports = echart_Model